package com.wc.算法竞赛进阶指南.搜索.树与图的遍历.可达性统计;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.BitSet;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/9/30 21:38
 * @description https://www.acwing.com/problem/content/166/
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 30010, M = 30010, idx = 1;
    static int[] h = new int[N], ne = new int[M], e = new int[M];
    static int[] q = new int[N];
    static int[] din = new int[N], seq = new int[N];
    static BitSet[] f = new BitSet[N];
    static int n, m;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        while (m-- > 0) {
            int a = sc.nextInt(), b = sc.nextInt();
            add(a, b);
            din[b]++;
        }
        topsort();
        for (int i = 1; i <= n; i++) f[i] = new BitSet();
        for (int x = n - 1; x >= 0; x--) {
            int t = seq[x];
            f[t].set(t, true);
            for (int i = h[t]; i > 0; i = ne[i]) {
                int j = e[i];
                f[t].or(f[j]);
            }
        }
        for(int i = 1; i <= n; i++){
            out.println(f[i].cardinality());
        }
        out.flush();
    }

    static void topsort() {
        int hh = 0, tt = -1;
        for (int i = 1; i <= n; i++) {
            if (din[i] == 0) q[++tt] = i;
        }
        int k = 0;
        while (hh <= tt) {
            int t = q[hh++];
            seq[k++] = t;
            for (int i = h[t]; i > 0; i = ne[i]) {
                int j = e[i];
                if (--din[j] == 0) q[++tt] = j;
            }
        }
    }


    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }


}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
